{"ast":null,"code":"import addEventListener from \"rc-util/es/Dom/addEventListener\";\nexport function getTargetRect(target) {\n  return target !== window ? target.getBoundingClientRect() : {\n    top: 0,\n    bottom: window.innerHeight\n  };\n}\nexport function getFixedTop(placeholderReact, targetRect, offsetTop) {\n  if (offsetTop !== undefined && targetRect.top > placeholderReact.top - offsetTop) {\n    return offsetTop + targetRect.top;\n  }\n  return undefined;\n}\nexport function getFixedBottom(placeholderReact, targetRect, offsetBottom) {\n  if (offsetBottom !== undefined && targetRect.bottom < placeholderReact.bottom + offsetBottom) {\n    const targetBottomOffset = window.innerHeight - targetRect.bottom;\n    return offsetBottom + targetBottomOffset;\n  }\n  return undefined;\n}\n// ======================== Observer ========================\nconst TRIGGER_EVENTS = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load'];\nlet observerEntities = [];\nexport function getObserverEntities() {\n  // Only used in test env. Can be removed if refactor.\n  return observerEntities;\n}\nexport function addObserveTarget(target, affix) {\n  if (!target) {\n    return;\n  }\n  let entity = observerEntities.find(item => item.target === target);\n  if (entity) {\n    entity.affixList.push(affix);\n  } else {\n    entity = {\n      target,\n      affixList: [affix],\n      eventHandlers: {}\n    };\n    observerEntities.push(entity);\n    // Add listener\n    TRIGGER_EVENTS.forEach(eventName => {\n      entity.eventHandlers[eventName] = addEventListener(target, eventName, () => {\n        entity.affixList.forEach(targetAffix => {\n          targetAffix.lazyUpdatePosition();\n        });\n      });\n    });\n  }\n}\nexport function removeObserveTarget(affix) {\n  const observerEntity = observerEntities.find(oriObserverEntity => {\n    const hasAffix = oriObserverEntity.affixList.some(item => item === affix);\n    if (hasAffix) {\n      oriObserverEntity.affixList = oriObserverEntity.affixList.filter(item => item !== affix);\n    }\n    return hasAffix;\n  });\n  if (observerEntity && observerEntity.affixList.length === 0) {\n    observerEntities = observerEntities.filter(item => item !== observerEntity);\n    // Remove listener\n    TRIGGER_EVENTS.forEach(eventName => {\n      const handler = observerEntity.eventHandlers[eventName];\n      if (handler && handler.remove) {\n        handler.remove();\n      }\n    });\n  }\n}","map":{"version":3,"names":["addEventListener","getTargetRect","target","window","getBoundingClientRect","top","bottom","innerHeight","getFixedTop","placeholderReact","targetRect","offsetTop","undefined","getFixedBottom","offsetBottom","targetBottomOffset","TRIGGER_EVENTS","observerEntities","getObserverEntities","addObserveTarget","affix","entity","find","item","affixList","push","eventHandlers","forEach","eventName","targetAffix","lazyUpdatePosition","removeObserveTarget","observerEntity","oriObserverEntity","hasAffix","some","filter","length","handler","remove"],"sources":["/data/messenger.client/node_modules/antd/es/affix/utils.js"],"sourcesContent":["import addEventListener from \"rc-util/es/Dom/addEventListener\";\nexport function getTargetRect(target) {\n  return target !== window ? target.getBoundingClientRect() : {\n    top: 0,\n    bottom: window.innerHeight\n  };\n}\nexport function getFixedTop(placeholderReact, targetRect, offsetTop) {\n  if (offsetTop !== undefined && targetRect.top > placeholderReact.top - offsetTop) {\n    return offsetTop + targetRect.top;\n  }\n  return undefined;\n}\nexport function getFixedBottom(placeholderReact, targetRect, offsetBottom) {\n  if (offsetBottom !== undefined && targetRect.bottom < placeholderReact.bottom + offsetBottom) {\n    const targetBottomOffset = window.innerHeight - targetRect.bottom;\n    return offsetBottom + targetBottomOffset;\n  }\n  return undefined;\n}\n// ======================== Observer ========================\nconst TRIGGER_EVENTS = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load'];\nlet observerEntities = [];\nexport function getObserverEntities() {\n  // Only used in test env. Can be removed if refactor.\n  return observerEntities;\n}\nexport function addObserveTarget(target, affix) {\n  if (!target) {\n    return;\n  }\n  let entity = observerEntities.find(item => item.target === target);\n  if (entity) {\n    entity.affixList.push(affix);\n  } else {\n    entity = {\n      target,\n      affixList: [affix],\n      eventHandlers: {}\n    };\n    observerEntities.push(entity);\n    // Add listener\n    TRIGGER_EVENTS.forEach(eventName => {\n      entity.eventHandlers[eventName] = addEventListener(target, eventName, () => {\n        entity.affixList.forEach(targetAffix => {\n          targetAffix.lazyUpdatePosition();\n        });\n      });\n    });\n  }\n}\nexport function removeObserveTarget(affix) {\n  const observerEntity = observerEntities.find(oriObserverEntity => {\n    const hasAffix = oriObserverEntity.affixList.some(item => item === affix);\n    if (hasAffix) {\n      oriObserverEntity.affixList = oriObserverEntity.affixList.filter(item => item !== affix);\n    }\n    return hasAffix;\n  });\n  if (observerEntity && observerEntity.affixList.length === 0) {\n    observerEntities = observerEntities.filter(item => item !== observerEntity);\n    // Remove listener\n    TRIGGER_EVENTS.forEach(eventName => {\n      const handler = observerEntity.eventHandlers[eventName];\n      if (handler && handler.remove) {\n        handler.remove();\n      }\n    });\n  }\n}"],"mappings":"AAAA,OAAOA,gBAAgB,MAAM,iCAAiC;AAC9D,OAAO,SAASC,aAAa,CAACC,MAAM,EAAE;EACpC,OAAOA,MAAM,KAAKC,MAAM,GAAGD,MAAM,CAACE,qBAAqB,EAAE,GAAG;IAC1DC,GAAG,EAAE,CAAC;IACNC,MAAM,EAAEH,MAAM,CAACI;EACjB,CAAC;AACH;AACA,OAAO,SAASC,WAAW,CAACC,gBAAgB,EAAEC,UAAU,EAAEC,SAAS,EAAE;EACnE,IAAIA,SAAS,KAAKC,SAAS,IAAIF,UAAU,CAACL,GAAG,GAAGI,gBAAgB,CAACJ,GAAG,GAAGM,SAAS,EAAE;IAChF,OAAOA,SAAS,GAAGD,UAAU,CAACL,GAAG;EACnC;EACA,OAAOO,SAAS;AAClB;AACA,OAAO,SAASC,cAAc,CAACJ,gBAAgB,EAAEC,UAAU,EAAEI,YAAY,EAAE;EACzE,IAAIA,YAAY,KAAKF,SAAS,IAAIF,UAAU,CAACJ,MAAM,GAAGG,gBAAgB,CAACH,MAAM,GAAGQ,YAAY,EAAE;IAC5F,MAAMC,kBAAkB,GAAGZ,MAAM,CAACI,WAAW,GAAGG,UAAU,CAACJ,MAAM;IACjE,OAAOQ,YAAY,GAAGC,kBAAkB;EAC1C;EACA,OAAOH,SAAS;AAClB;AACA;AACA,MAAMI,cAAc,GAAG,CAAC,Q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